Search


เขียนโค้ดให้ปลอดภัย
ก็เป็นทักษะอย่างห...

  • Share this:


เขียนโค้ดให้ปลอดภัย
ก็เป็นทักษะอย่างหนึ่งที่ควรรู้
ตัวอย่างเป็นโค้ด PHP
.
ให้คิดว่าตัวแปร $value มีค่าเป็นสตริง
ข้างในอยู่ในรูปแบบตัวเลข
เช่น เอาไว้ใช่เก็บพวกเลข session id หรือ token อะไรก้ได้
.
แล้วสมมติว่า $value
มันดันรับค่าเป็น '0e......' (ตามด้วยตัวเลข)
เช่น
$value = '0e125996890409996004'
.
แบบนี้ถ้าใช่การเปรียบเทียบ
ในนิพจน์ของประโยคเปรียบเทียบ
ใช้โดยไม่ระวังตัวแล้วละก็
.
ก็อาจเกิดช่องโหว่
ถ้าเบาๆ หน่อยก็เป็น bug นิดหน่อย
.
แต่ถ้าร้ายแรง ก็จะกลายเป็นช่องโหว่ความปลอดภัยได้ด้วย
ยิ่งในเงื่อนไข
มันเอาไว้เช็คพวกสิทธิต่างๆ ด้วยแล้วละก็
ถ้าเช็คพลาด หลุดไปได้
ก็จะเข้าถึงสิ่งที่ไม่ควรเข้าถึงได้
แบบนี้ hacker นั่งยิ้มเลย
.
✍ เขียนโดย โปรแกรมเมอร์ไทย thai programmer
Write the code safely.
It's one skill to know.
Example is a PHP code
.
To think that $value variant is worth a string.
Inside is in number form.
For example, keep those session id or token numbers.
.
And assume $value
It accepts value as '0 e......' (followed by numbers)
For example,
$value = '0e125996890409996004'
.
This is if it's a comparison.
In the litigation of comparison sentences
Use it without being careful.
.
Maybe a loophole.
If it's a little bit of a bug.
.
But if it's deadly, it can also be a safety loophole.
The more in terms.
It's for checking the rights too.
If you miss it, you can slip it.
It's gonna reach the unaccountable
This is a hacker sitting and smiling.
.
✍ Written by Thai programmer thai coderTranslated


Tags:

About author
เพจนี้เปิดใช้งานเมื่อ 22 มิถุนายน 2014 เพจนี้เน้นหนักไป ทางการเขียนโปรแกรม คอมพิวเตอร์ และไอที ล้วน ๆ แบบฮาร์ดคอ หรือจะไร้สาระ มุกตลกขำ
ให้สาระด้านไอที คอมพิวเตอร์ และอาชีพโปรแกรมเมอร์ และสายงานด้านคอมพิวเตอร์
View all posts